# Unveiling: the Electoral Consequences of an Exogenous Mid-Campaign Court Ruling replication file

This replication file contains all the files and data necessary for the replication of the Unveiling: the Electoral Consequences of an Exogenous Mid-Campaign Court Ruling paper.

To reproduce the analyses there are two options: with or without packrat. The packrat method requires the packrat package but is a permanent stable version of the replication that includes all the libraries and packages required as they were at the time of the papers publication.

With packrat:
* Run the command <packrat::unbundle("unveiling_replication.tar.gz")> in R to unbundle and install all the packages in a local library. This will take some time.
* Open the newly unzipped folder and open unveiling.Rproj in RStudio
* Run prep.Rmd to recode and otherwise modify the raw data files and save them as .rds files in the data/ready/ directory
* Run analysis.Rmd to produce all tables and figures for the table.

Without packrat:
* Download CES2015_Combined_R.RData downloaded from https://ces-eec.arts.ubc.ca/english-section/surveys/
* Download LPP2015.RData from https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/DACHKP
* Open unveiling.Rproj in RStudio
* Modify the paths for the files you downloaded and then run prep.Rmd, to recode and otherwise modify the raw data files and save them as .rds files in the data/ready/ directory. You may need to install packages that you do not already have and subsequent package changes may break the code.
* Run analysis.Rmd to produce all tables and figures for the paper. Again, you may need to install packages that you do not already have and subsequent package changes may break the code.

## Data

The data directory contains:

- frlsd.cat downloaded from https://www.poltext.org/fr/donnees-et-analyses/lexicoder (checked Jan 2020)
- CES2015_Combined_R.RData downloaded from https://ces-eec.arts.ubc.ca/english-section/surveys/ and associated codebook (checked Jan 2020) 
- LPP2015.RData from https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/DACHKP and associated codebook (checked Jan 2020)
- media.csv which is described in more detail below
- media_sentiment.csv which is described in more detail below
- google_trends.csv which is an extract from google trends and can be downloaded separately here https://trends.google.com/trends/explore?date=2015-06-30%202015-10-18&geo=CA-QC&q=niqab

For both media.csv, and media_sentiment.csv, contact the authors if you are interested in getting additional information about the collected articles or the process used to produce these intermediary data files. The full text of the articles has not been included as many of the articles are owned by private media companies and are not publicly available.

### media.csv

A 16544*6 table that captures a large segment of print media commentary on the economy and the niqab during the 2015 Canadian Federal Election. English-language media was collected on December 20, 2018 using searches on LexisNexus for a period from July 1, 2015 to November 1, 2015 with the search term 'economy' or 'niqab' and a particular journal name. For French-language papers, Eureka was used to collect all articles with 'économie' and 'niqab' for the same time period. A similar search with key term + journal name was effected on January 13, 2019. Full lists of the journals searched are found in the Appendix of the paper. The full text from the Eureka searches was downloaded for media_sentiment.csv.

### media_sentiment.csv 

A 493*11 table that contains content for all articles that were identified with the keyword niqab. Note that there are fewer articles here (n = 489) as compared to niqab French-language articles in the media.csv during the same time period. For the text analysis, only articles that contained 200 or more words were analyzed (articles beneath this threshold were often letters to the editor, corrections, or otherwise less-meaningful "articles"). We have computed the number of mentions of the niqab, the number of times liberal-associated terms appear in the body of the text (lpc_mentions), the number of times ndp-associated terms appear in the body of the text (ndp_mentions), the number of proximate word tokens (n=15) identified by french-lexicoder as having positive or negative sentiment near liberal terms and ndp terms (positive_lpc, negative_lpc, positive_ndp, negative_ndp). The script to compute these measures is available upon request but requires the original full text of the articles which are not shared here for reasons described above.

